// 复杂的自定义覆盖物 
function ComplexCustomOverlay(point, text, mouseoverText, btnType, reactFunc){
  this._point = point;
  this._text = text;
  this._overText = mouseoverText;
  this._click = reactFunc;
  this._btnType = btnType;
}
ComplexCustomOverlay.prototype = new BMap.Overlay();
ComplexCustomOverlay.prototype.initialize = function(map){
  this._map = map;
  var div = this._div = document.createElement("div");
  if(this._btnType == "cancle"){
	  div.style.position = "absolute";
	  div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
	  div.style.backgroundColor = "#b1b1b1";
	  div.style.border = "1px solid #32B5CB";
	  div.style.color = "white";
	  div.style.height = "26px";
	  div.style.padding = "0px 18px";
	  div.style.lineHeight = "26px";
	  div.style.whiteSpace = "nowrap";
	  div.style.MozUserSelect = "none";
	  div.style.fontSize = "12px"
	  div.style.cursor = "pointer";
  }else if(this._btnType == "submit"){
	  div.style.position = "absolute";
	  div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
	  div.style.backgroundColor = "#32b5cb";
	  div.style.border = "1px solid #32B5CB";
	  div.style.color = "white";
	  div.style.height = "26px";
	  div.style.padding = "0px 18px";
	  div.style.lineHeight = "26px";
	  div.style.whiteSpace = "nowrap";
	  div.style.MozUserSelect = "none";
	  div.style.fontSize = "12px"
	  div.style.cursor = "pointer";
	  
  }
  
  var span = this._span = document.createElement("span");
  div.appendChild(span);
  //span.appendChild("<spa>X</span>");
  span.appendChild(document.createTextNode(this._text));      
  var that = this;
  
  div.onclick = this._click;
  
  //如果有问题，检查这里的map变量，百度demo中此处取得是mp全局变量，而不是方法内的map，但现在功能能实现，先这样
  map.getPanes().labelPane.appendChild(div);
  
  return div;
}
ComplexCustomOverlay.prototype.draw = function(){
  var map = this._map;
  var pixel = map.pointToOverlayPixel(this._point);
  //设置
  if(this._btnType == "cancle"){
	  this._div.style.left = pixel.x - 120 + "px";
  }else if(this._btnType == "submit"){
	  this._div.style.left = pixel.x - 60 + "px";
  }
  this._div.style.top  = pixel.y + 1 + "px";
}
